<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/11/1
 * Time: 16:54
 */

if (!defined('IN_DISCUZ')) {
    exit('Access Denied');
}

if(empty($_POST)){
    die('<script>alert("内容为空,请重新选择要添加 的数据!");history.go(-1)</script>');
}



//将接受到的数据写入数据库中
$newAddress = [];
$newAddress[] = $_POST['address'];
$newAddress[] = $_POST['address2'];
$localData = [
    'username' =>$_G['username'],
    'channelName' => $_POST['channelName'],
    'channelDescribe' => $_POST['channelDescribe'],
    'start' => $_POST['start'],
    'end' => $_POST['end'],
    'logo' => $_POST['logo'],
    'outputSourceType'=>$_POST['outputSourceType'],
    'outputRate' => json_encode($_POST['outputRate']),
    'watermarkId' => $_POST['watermarkId'],
    'channelId' =>$_POST['channelId'],
    'downstream_address'=>json_encode($newAddress,JSON_UNESCAPED_UNICODE)
];

$data = C::t('#zhibo#zhibo')->add($localData);



if ($data) {
    echo '<script>alert("添加成功111")</script>';
} else {
    echo '<script>alert("添加失败")</script>';
}